package debtbundler.domain.entity;

import java.util.List;

import debtbundler.domain.entity.impl.ListenableEntity;

public interface BalanceSheet extends Entity, ListenableEntity {
	
	/**
	 * @return	name of this balance sheet
	 */
	public String getName();
	
	/**
	 * @param name	name for this balance sheet
	 */
	public void setName(String name);
	
	/**
	 * @return	persons in this sheet (not null)
	 */
	public List<Person> getPersons();
	
	/**
	 * Swaps indices of persons in the <code>getPersons()</code> list.
	 * The rules defined in <code>Collections.swap(List, int, int)</code> apply.
	 * 
	 * @param i		the index of one person to swap
	 * @param j		the index of the other person to swap
	 * @see #getPersons()
	 * @see Collections#swap(List, int, int)
	 */
	public void swapPersons(int i, int j);
	
	/**
	 * @return	shared costs in this sheet (not null)
	 */
	public List<SharedCost> getSharedCosts();	
	
	/**
	 * Swaps indices of shared costs in the <code>getSharedCosts()</code> list.
	 * The rules defined in <code>Collections.swap(List, int, int)</code> apply.
	 * 
	 * @param i		the index of one cost to swap
	 * @param j		the index of the other cost to swap
	 * @see #getSharedCosts()
	 * @see Collections#swap(List, int, int)
	 */
	public void swapSharedCosts(int i, int j);
	
	/**
	 * @return	money pools of this sheet (not null)
	 */
	public List<MoneyPool> getMoneyPools();
	
	/**
	 * Swaps indices of money pools in the <code>getMoneyPools()</code> list.
	 * The rules defined in <code>Collections.swap(List, int, int)</code> apply.
	 * 
	 * @param i		the index of one pool to swap
	 * @param j		the index of the other pool to swap
	 * @see #getMoneyPools()
	 * @see Collections#swap(List, int, int)
	 */
	public void swapMoneyPools(int i, int j);	
	
	/**
	 * Adds a money pool on this sheet.
	 * 
	 * @param pool	the pool to add
	 * @return		<code>true</code> if the pool was added
	 */
	public boolean addMoneyPool(MoneyPool pool);
	
	/**
	 * Removes a money pool from this sheet.
	 * 
	 * @param pool	the pool to remove
	 * @return		<code>true</code> if the pool was removed
	 */
	boolean removeMoneyPool(MoneyPool pool);
	
	/**
	 * "Signs" in the name of the current user that the debts 
	 * in this balance sheet have been settled.    
	 * 
	 * @return	the signature created
	 */
	public Signature signAsSettled();
	
	/**
	 * If the debts in this balance sheet have been settled, 
	 * returns signature the signature. Otherwise returns 
	 * <code>null</code>.
	 * 
	 * @return	signature for the resolution of debts from this sheet,
	 * 			<code>null</code> if this sheet is not signed
	 * 
	 * @see signAsSettled()
	 */
	public Signature getSignature();
	
	/**
	 * Removes the signature on this balance sheet.
	 */
	public void removeSignature();	

	/**
	 * @return	debts in this sheet
	 */
	public List<Debt> getDebts();


}
